fix(grep): grep -r on single file returns empty#1080
Merged
Conversation
OverlayFs::read_dir() returned Ok(vec![]) for file paths instead of Err, causing grep -r's fallback file-read path to never trigger. Added explicit file-type check in OverlayFs::read_dir(). Closes #1074
Directly tests that read_dir returns Err for file paths, per spec requirement (specs/003-vfs.md line 459).
bbc9fcd to
ad4aa52
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
OverlayFs::read_dir()returnedOk(vec![])for file paths instead ofErr("not a directory"), so grep -r's fallback file-read branch never triggeredOverlayFs::read_dir()— if the path resolves to a non-directory in either layer, return an error (per spec requirement inspecs/003-vfs.mdline 459)test_grep_recursive_single_file— grep -r on single file with InMemoryFstest_grep_recursive_single_file_overlay— grep -r on single file with OverlayFs (actual bug path)test_read_dir_on_file_returns_error— direct OverlayFs::read_dir correctness testTest plan
cargo test -p bashkit— all 2022 tests passcargo fmt --checkcleancargo clippy --all-targets -- -D warningscleanCloses #1074